package iterator;

public class ChromeMenu implements Menu {
    static final int MAX_ITEMS = 10;
    MenuItem[] menuItems;
    int cur;
    public ChromeMenu() {
        menuItems = new MenuItem[MAX_ITEMS];
        // 在构造器中模拟数据
        addItem("返回", "backIcon");
        addItem("重新加载", "reloadIcon");
    }

    public void addItem(String name, String icon) {
        if(cur + 1 >= MAX_ITEMS) return;
        menuItems[cur++] = new MenuItem(name, icon);
    }

    @Override
    public Iterator createIterator() {
        return new ChromeMenuIterator(this.menuItems);
    }
}
